package com.ruoyi.web.ydz.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.ydz.domain.ReplyLike;
import com.ruoyi.web.ydz.service.IReplyLikeService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;

import java.util.List;

/**
 * 帖子评论点赞Controller
 * 
 * @author ruoyi
 * @date 2024-10-29
 */
@RestController
@RequestMapping("/ydz/replylike")
public class ReplyLikeController extends BaseController
{
    @Resource
    private IReplyLikeService replyLikeService;

    /**
     * 查询帖子评论点赞列表
     */
    @PreAuthorize("@ss.hasPermi('ydz:replylike:list')")
    @GetMapping("/list")
    public TableDataInfo list(ReplyLike replyLike)
    {
        startPage();
        List<ReplyLike> list = replyLikeService.selectReplyLikeList(replyLike);
        return getDataTable(list);
    }

    /**
     * 导出帖子评论点赞列表
     */
    @PreAuthorize("@ss.hasPermi('ydz:replylike:export')")
    @Log(title = "帖子评论点赞", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ReplyLike replyLike)
    {
        List<ReplyLike> list = replyLikeService.selectReplyLikeList(replyLike);
        ExcelUtil<ReplyLike> util = new ExcelUtil<ReplyLike>(ReplyLike.class);
        util.exportExcel(response, list, "帖子评论点赞数据");
    }

    /**
     * 获取帖子评论点赞详细信息
     */
    @PreAuthorize("@ss.hasPermi('ydz:replylike:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(replyLikeService.selectReplyLikeById(id));
    }

    /**
     * 新增帖子评论点赞
     */
    @Log(title = "帖子评论点赞", businessType = BusinessType.INSERT)
    @RequestMapping("/like")
    public AjaxResult add(@RequestBody ReplyLike replyLike)
    {
        return replyLikeService.insertReplyLike(replyLike);
    }

    /**
     * 修改帖子评论点赞
     */
    @PreAuthorize("@ss.hasPermi('ydz:replylike:edit')")
    @Log(title = "帖子评论点赞", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReplyLike replyLike)
    {
        return toAjax(replyLikeService.updateReplyLike(replyLike));
    }

    /**
     * 删除帖子评论点赞
     */
    @PreAuthorize("@ss.hasPermi('ydz:replylike:remove')")
    @Log(title = "帖子评论点赞", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(replyLikeService.deleteReplyLikeByIds(ids));
    }
}
